Skip to content

Validate NCHWc reorder channel layout - #32552

Open
Akshay Sonawane (apsonawane) wants to merge 4 commits into
mainfrom
fix/reorder-output-channel-layout
Open

Akshay Sonawane (apsonawane) wants to merge 4 commits into
mainfrom
fix/reorder-output-channel-layout

Conversation

@apsonawane

Copy link
Copy Markdown
Contributor

This pull request strengthens input validation in the ReorderOutput operator for NCHWc tensors and adds a new unit test to ensure correct error handling for misaligned input channels. The main focus is to enforce stricter requirements on input channel alignment and to verify this behavior with automated testing.

Operator input validation improvements:

  • Updated ReorderOutput::Compute in nchwc_ops.cc to enforce that the input channel count is a multiple of the NCHWc block size, and that the number of channels requested is properly aligned. The error message was also improved for clarity.

Testing enhancements:

  • Added a new unit test ReorderOutputRejectsUnalignedInputChannels in nchwc_ops_test.cc to verify that the operator correctly rejects inputs where the channel count is not NCHWc block-aligned, ensuring that the stricter validation is covered.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test does not cover the newly added excessive-padding rejection condition.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Strengthens NCHWc ReorderOutput channel-layout validation.

Changes:

  • Validates block alignment and requested channel count.
  • Adds a rejection test for unaligned input channels.
File summaries
File Description
onnxruntime/contrib_ops/cpu/nchwc_ops.cc Enforces valid NCHWc channel padding.
onnxruntime/test/contrib_ops/nchwc_ops_test.cc Tests rejection of unaligned channels.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread onnxruntime/test/contrib_ops/nchwc_ops_test.cc
@mirounga
mirounga self-requested a review September 16, 2026 17:12
Add the aligned input case where ReorderOutput receives one complete channel block beyond the requested output channels.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The test file has an undeclared variable and mismatched namespace braces that prevent compilation.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread onnxruntime/test/contrib_ops/nchwc_ops_test.cc
Restore the anonymous namespace and the extra-channel-block test setup lost during the main merge, fixing the test translation unit compile errors across CI configurations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The validation is correct, bounded, and adequately tested.

Review effort: Balanced
Findings: None

Resolved since last review (1)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants